Function Reference

TrayGetMsg

Polls the tray to see if any events have occurred.

TrayGetMsg()

 

Parameters

None.

 

Return Value

Returns an event.
The "event" returned is the control ID of the control sending the message, or it is a special event (like the mouse clicking on the tray icon). Or if there is no message, the event is 0.


Event IDs
0 No event
Control ID the ID of the control sending the message
$TRAY_EVENT_PRIMARYDOWN the primary mouse button was pressed
$TRAY_EVENT_PRIMARYUP the primary mouse button was released
$TRAY_EVENT_SECONDARYDOWN the secondary mouse button was pressed
$TRAY_EVENT_SECONDARYUP the secondary mouse button was released
$TRAY_EVENT_PRIMARYDOUBLE the primary mouse button was double pressed
$TRAY_EVENT_SECONDARYDOUBLE the secondary mouse button was double pressed

 

Remarks

This function automatically idles the CPU when required so that it can be safely used in tight loops without hogging all the CPU.

 

Related

TrayCreateItem, TrayCreateMenu

 

Example


#Include <Constants.au3>
#NoTrayIcon

Opt("TrayMenuMode",1)   ; Default tray menu items (Script Paused/Exit) will not be shown.

$settingsitem   = TrayCreateMenu("Settings")
$displayitem    = TrayCreateItem("Display", $settingsitem)
$printeritem    = TrayCreateItem("Printer", $settingsitem)
TrayCreateItem("")
$aboutitem      = TrayCreateItem("About")
TrayCreateItem("")
$exititem       = TrayCreateItem("Exit")

TraySetState()

While 1
    $msg = TrayGetMsg()
    Select
        Case $msg = 0
            ContinueLoop
        Case $msg = $aboutitem
            Msgbox(64,"About:","AutoIt3-Tray-sample")
        Case $msg = $exititem
            ExitLoop
    EndSelect
WEnd

Exit